package main

import (
	"fmt"
	"strings"
)

// https://leetcode.cn/problems/longest-substring-without-repeating-characters/
// 寻找最长无重复字符串
// 使用滑动窗口
func lengthOfLongestSubstring(s string) int {
	if s == "" {
		return 0
	}
	//var nnn []string
	var temp string
	var longest int = 1
	for i := 0; i < len(s); i++ {
		for j := i + 1; j <= len(s); j++ {
			//nnn := append(nnn, s[j-1:j])
			s2 := s[j-1 : j]
			if strings.Index(temp, s2) != -1 {
				if len(temp) > longest {
					longest = len(temp)
				}
				temp = ""
				break
			}
			temp += s2
		}
		if len(temp) > longest {
			longest = len(temp)
		}
	}
	return longest
}
func main() {
	substring := lengthOfLongestSubstring("au")
	fmt.Println(substring)
}
